 _VERSION-NUMBER AB_v9r12 GUI adm2


 _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS w-html 

/*------------------------------------------------------------------------

  File: 

  Description: 

  Input Parameters:
      <none>

  Output Parameters:
      <none>

  Author: 

  Created: 

------------------------------------------------------------------------*/
/*           This .W file was created with AppBuilder.                  */
/*----------------------------------------------------------------------*/

/* Create an unnamed pool to store all the widgets created 
     by this procedure. This is a good default which assures
     that this procedure's triggers and internal procedures 
     will execute in this procedure's storage, and that proper
     cleanup will occur on deletion of the procedure. */
CREATE WIDGET-POOL.

/* ***************************  Definitions  ************************** */

/* Preprocessor Definitions ---                                         */

/* Parameters Definitions ---                                           */

/* Local Variable Definitions ---                                       */

DEF NEW SHARED BUFFER doce     FOR doce.
DEF NEW SHARED BUFFER docld    FOR docld.
DEF            BUFFER wk-doce  FOR doce.

DEF NEW SHARED VAR a-lang          AS    INTEGER                   NO-UNDO.
DEF            VAR nb-ligne        AS    INTEGER                   NO-UNDO.
DEF            VAR i               AS    INTEGER                   NO-UNDO.
DEF            VAR j               AS    INTEGER                   NO-UNDO.
DEF            VAR nomprg          AS    CHARACTER                 NO-UNDO.
DEF            VAR lab-bouton      AS    CHARACTER EXTENT 5        NO-UNDO.
DEF            VAR action          AS    CHARACTER                 NO-UNDO.

DEF            VAR buf-nocli       LIKE doce.noadrf                NO-UNDO.
DEF            VAR buf-csmt        LIKE doce.csmtf                 NO-UNDO.
DEF            VAR buf-prefix      LIKE doce.prefix                NO-UNDO.
DEF            VAR buf-nodoc       LIKE doce.nodoc                 NO-UNDO.
DEF            VAR buf-rabais      LIKE docld.rabais               NO-UNDO.


DEF            VAR buf-pumb         LIKE docld.punite NO-UNDO.
DEF            VAR buf-punite       LIKE docld.punite NO-UNDO.
DEF            VAR buf-unitp        LIKE docld.unitp  NO-UNDO.
DEF            VAR buf-nocpt        LIKE docld.nocpt  NO-UNDO.
DEF            VAR buf-taxi         LIKE docld.taxi   NO-UNDO.

DEF            VAR flag-art        AS   LOGICAL                    NO-UNDO.
DEF            VAR flag-rem        AS   LOGICAL                    NO-UNDO.
DEF            VAR flag-lgdoc      AS   LOGICAL                    NO-UNDO.

DEF            VAR buf-qte         AS   INTEGER             NO-UNDO.
DEF            VAR buf-ref         AS   CHARACTER           NO-UNDO.

DEF NEW SHARED VAR nomchamp        AS CHARACTER EXTENT 2 
                   INIT ["ref","qte"] NO-UNDO.

/* _UIB-CODE-BLOCK-END */

 _UIB-PREPROCESSOR-BLOCK 


/* ********************  Preprocessor Definitions  ******************** */

&Scoped-define PROCEDURE-TYPE Web-Object
&Scoped-define DB-AWARE no

&Scoped-define WEB-FILE commande.htm

/* Name of first Frame and/or Browse and/or first Query                 */
&Scoped-define FRAME-NAME Web-Frame

/* Standard List Definitions                                            */
&Scoped-Define ENABLED-OBJECTS ab_unmap.alang ab_unmap.monnaie_doc ~
ab_unmap.article_bas ab_unmap.article_ent ab_unmap.par-retour ~
ab_unmap.lablien2 ab_unmap.lablien3 ab_unmap.refs ab_unmap.article_sais ~
ab_unmap.par-id ab_unmap.par-nosui ab_unmap.Err_date ab_unmap.Err_deci ~
ab_unmap.navigue 
&Scoped-Define DISPLAYED-OBJECTS ab_unmap.alang ab_unmap.monnaie_doc ~
ab_unmap.article_bas ab_unmap.article_ent ab_unmap.par-retour ~
ab_unmap.lablien2 ab_unmap.lablien3 ab_unmap.refs ab_unmap.article_sais ~
ab_unmap.par-id ab_unmap.par-nosui ab_unmap.Err_date ab_unmap.Err_deci ~
ab_unmap.navigue 

/* Custom List Definitions                                              */
/* List-1,List-2,List-3,List-4,List-5,List-6                            */

/* _UIB-PREPROCESSOR-BLOCK-END */

 _PROCEDURE-SETTINGS

/* Settings for THIS-PROCEDURE
   Type: Web-Object
   Allow: Query
   Frames: 1
   Add Fields to: Neither
   Editing: Special-Events-Only
   Events: web.output,web.input
   Other Settings: COMPILE
   Temp-Tables and Buffers:
      TABLE: ab_unmap W "?" ?  
      ADDITIONAL-FIELDS:
          FIELD alang AS CHARACTER FORMAT "X(256)":U 
          FIELD article_bas AS CHARACTER FORMAT "X(256)":U 
          FIELD article_ent AS CHARACTER FORMAT "X(256)":U 
          FIELD article_sais AS CHARACTER FORMAT "X(256)":U 
          FIELD Err_date AS CHARACTER FORMAT "X(256)":U 
          FIELD Err_deci AS CHARACTER FORMAT "X(256)":U 
          FIELD lablien2 AS CHARACTER FORMAT "X(256)":U 
          FIELD lablien3 AS CHARACTER FORMAT "X(256)":U 
          FIELD monnaie_doc AS CHARACTER FORMAT "X(256)":U 
          FIELD navigue AS CHARACTER FORMAT "X(256)":U 
          FIELD par-id AS CHARACTER FORMAT "X(256)":U 
          FIELD par-nosui AS CHARACTER FORMAT "X(256)":U 
          FIELD par-retour AS CHARACTER FORMAT "X(256)":U 
          FIELD refs AS CHARACTER FORMAT "X(256)":U 
      END-FIELDS.
   END-TABLES.
 */
_END-PROCEDURE-SETTINGS
 _CREATE-WINDOW

/* DESIGN Window definition (used by the UIB) 
  CREATE WINDOW w-html ASSIGN
         HEIGHT             = 14.14
         WIDTH              = 57.6.
/* END WINDOW DEFINITION */
                                                                        */

 _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB w-html 

/* *********************** Included-Libraries ************************* */

{src/web2/html-map.i}

/* _UIB-CODE-BLOCK-END */

 _RUN-TIME-ATTRIBUTES

/* SETTINGS FOR WINDOW w-html
  VISIBLE,,RUN-PERSISTENT                                               */
/* SETTINGS FOR FRAME Web-Frame
   UNDERLINE                                                            */
/* SETTINGS FOR FILL-IN ab_unmap.alang IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.article_bas IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.article_ent IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.article_sais IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.Err_date IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.Err_deci IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.lablien2 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.lablien3 IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.monnaie_doc IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.navigue IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.par-id IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.par-nosui IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.par-retour IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* SETTINGS FOR FILL-IN ab_unmap.refs IN FRAME Web-Frame
   ALIGN-L EXP-LABEL EXP-FORMAT EXP-HELP                                */
/* _RUN-TIME-ATTRIBUTES-END */

 _UIB-CODE-BLOCK _CONTROL ab_unmap.article_bas w-html WEB.output

PROCEDURE ab_unmap.article_bas.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DEF VAR nom_page        AS    CHARACTER         NO-UNDO.
  DEF VAR ligne           AS    CHARACTER         NO-UNDO.
  DEF VAR lst-tag         AS    CHARACTER         NO-UNDO.
  DEF VAR pos             AS    INTEGER           NO-UNDO.
  DEF VAR txt_aff         AS    CHARACTER         NO-UNDO.

  DO WITH FRAME {&FRAME-NAME}:
  
      IF NOT flag-lgdoc THEN RETURN.

      txt_aff = "". 

      FIND erreur WHERE erreur.noerr = 101057
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + IF NOT AVAILABLE erreur THEN "&nbsp;" 
                          ELSE erreur.libel.

      FIND erreur WHERE erreur.noerr = 101012
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + erreur.libel
              + "#" + STRING(doce.totme - doce.totqte - doce.totmtn + doce.totme ,"->>>,>>9.99").
      
      FIND erreur WHERE erreur.noerr = 101058
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + IF NOT AVAILABLE erreur THEN "&nbsp;" 
                          ELSE erreur.libel.     
      
      FIND erreur WHERE erreur.noerr = 101014
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + erreur.libel
              + "#" + STRING(doce.totqte + doce.totmtn - doce.totme,"->>>,>>9.99").
      
      FIND erreur WHERE erreur.noerr = 101059
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + IF NOT AVAILABLE erreur THEN "&nbsp;" 
                          ELSE erreur.libel.

      FIND erreur WHERE erreur.noerr = 101013
                    AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
      txt_aff = txt_aff + "#" + erreur.libel
              + "#" + STRING(doce.totme,"->>>,>>9.99").

      txt_aff = txt_aff + "#" + doce.codmon.


      nom_page = SEARCH("commande_bas.htm").
      IF nom_page = ? THEN RETURN.
      INPUT FROM VALUE(nom_page).
      REPEAT:
         IMPORT UNFORMATTED ligne.
         pos = INDEX(ligne,"<!--WSTAG").
         IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
         IF pos = 0 THEN {&out} ligne SKIP.
         ELSE DO:
            RUN decode_tag(ligne,"champ",OUTPUT lst-tag).
            DO i = 1 TO NUM-ENTRIES(lst-tag).
               RUN remplace_tag ("champ",10,ENTRY(i,lst-tag),txt_aff,INPUT-OUTPUT ligne).
            END.
            {&out} ligne SKIP.
         END.
      END.
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _CONTROL ab_unmap.article_ent w-html WEB.output

PROCEDURE ab_unmap.article_ent.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  DEF VAR nom_page        AS CHARACTER      NO-UNDO.
  DEF VAR ligne           AS CHARACTER      NO-UNDO.
  DEF VAR lst-tag         AS CHARACTER      NO-UNDO.
  DEF VAR pos             AS INTEGER        NO-UNDO.
  DEF VAR nb              AS INTEGER        NO-UNDO.
  DEF VAR buf-mess        AS CHARACTER      NO-UNDO.
  
  DO WITH FRAME {&FRAME-NAME}:
  
      buf-mess = "".

      IF NOT flag-lgdoc THEN DO:
         FIND erreur WHERE erreur.noerr = 101054
                       AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
         IF AVAILABLE erreur THEN buf-mess = buf-mess + erreur.libel.
         nom_page = SEARCH("commande_vide.htm").
      END.
      ELSE DO:
         FIND erreur WHERE erreur.noerr = 101009
                        AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
         IF AVAILABLE erreur THEN buf-mess = buf-mess + erreur.libel. 
         nom_page = SEARCH("commande_entete.htm").


         IF flag-lgdoc AND (doce.noadrf = 1000 OR doce.noadrf = 1001) THEN DO:
            FIND erreur WHERE erreur.noerr = 101055
                           AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
            buf-mess = buf-mess + "#" + ENTRY(1,erreur.libel,"#").

            buf-mess = buf-mess + "#" + "<input name=~"monnaie~" type=~"radio~" value=~"CHF~" onClick=~"document.commande.submit();~"".
            IF doce.codmon = "CHF" THEN  buf-mess = buf-mess + " checked".

            buf-mess = buf-mess + ">".
            buf-mess = buf-mess + "#" + ENTRY(2,erreur.libel,"#").

            buf-mess = buf-mess + "#" + "<input name=~"monnaie~" type=~"radio~" value=~"EUR~" onClick=~"document.commande.submit();~"".
            IF doce.codmon = "EUR" THEN  buf-mess = buf-mess + " checked".
            buf-mess = buf-mess + ">".
         END.

      END.

      nb = NUM-ENTRIES(buf-mess,"#").

      IF nom_page = ? THEN RETURN.
      INPUT FROM VALUE(nom_page).
      REPEAT:
         IMPORT UNFORMATTED ligne.
         pos = INDEX(ligne,"<!--WSTAG").
         IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
         IF pos = 0 THEN {&out} ligne SKIP.
         ELSE DO:
            RUN decode_tag(ligne,"label",OUTPUT lst-tag).
            DO i = 1 TO NUM-ENTRIES(lst-tag).
               RUN remplace_tag ("label",nb,ENTRY(i,lst-tag),buf-mess,INPUT-OUTPUT ligne).
            END.
            {&out} ligne SKIP.
         END.
      END.
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _CONTROL ab_unmap.article_sais w-html WEB.output

PROCEDURE ab_unmap.article_sais.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.

  DEF VAR flag-trouve     AS    LOGICAL           NO-UNDO.
  DEF VAR txt_aff         AS    CHARACTER         NO-UNDO.
  DEF VAR nom_page        AS    CHARACTER         NO-UNDO.
  DEF VAR ligne           AS    CHARACTER         NO-UNDO.
  DEF VAR lst-tag         AS    CHARACTER         NO-UNDO.
  DEF VAR pos             AS    INTEGER           NO-UNDO.
  DEF VAR i               AS    INTEGER           NO-UNDO.
  DEF VAR num             AS    INTEGER           NO-UNDO.
  
  FOR EACH docld WHERE docld.nosoc  = doce.nosoc
                   AND docld.typdoc = doce.typdoc
                   AND docld.prefix = doce.prefix
                   AND docld.nodoc  = doce.nodoc NO-LOCK:

      IF docld.ref = "" THEN NEXT.

      FIND arti WHERE arti.nosoc = docld.nosoc
                  AND arti.ref   = docld.ref NO-LOCK NO-ERROR.

      IF NOT AVAILABLE arti THEN NEXT.
            flag-art = TRUE.
      txt_aff = "<a href=~"commande_delart.w?RowId=" + STRING(ROWID(docld)) + "&retour=commande.w&lang=" + STRING(a-lang)
              + "~"><img border=~"0~" src=~"/images/annuler.gif~"></a>".

      txt_aff = txt_aff + "#" + "<input type=~"text~" name=~"qtes" + STRING(docld.noseq)
              + "~" value=~"" + STRING(docld.qtec) + "~" size=~"6~" onchange=~"return ctrlZone(this,3,'4');~""
              + " style=~"text-align: right~">".

      txt_aff = txt_aff + "#" + arti.titre + "#" + arti.auteur + "#" + ENTRY(1,arti.DESCRIPTION,CHR(10)).
      txt_aff = txt_aff + "#" + STRING(docld.punite,"zz,zz9.99").
      txt_aff = txt_aff + "#" + STRING(docld.rabais,"zz9.99 %").
      txt_aff = txt_aff + "#" + STRING(docld.montne,"zzz,zz9.99").
      txt_aff = txt_aff + "#" + doce.codmon + "#" + docld.ref.

      nom_page = SEARCH("commande_ligne.htm").
      IF nom_page = ? THEN RETURN.
      INPUT FROM VALUE(nom_page).
      REPEAT:
         IMPORT UNFORMATTED ligne.
         pos = INDEX(ligne,"<!--WSTAG").
         IF TRIM(ligne) BEGINS "<!--" AND pos = 0 THEN NEXT.
         IF pos = 0 THEN {&out} ligne SKIP.
         ELSE DO:
            RUN decode_tag(ligne,"champ",OUTPUT lst-tag).
            DO i = 1 TO NUM-ENTRIES(lst-tag).
               RUN remplace_tag ("champ",10,ENTRY(i,lst-tag),txt_aff,INPUT-OUTPUT ligne).
            END.
            {&out} ligne SKIP.
         END.
      END.
  END.
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _CONTROL ab_unmap.Err_deci w-html WEB.output

PROCEDURE ab_unmap.Err_deci.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  RUN aff_label (100089).
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _CONTROL ab_unmap.lablien2 w-html WEB.output

PROCEDURE ab_unmap.lablien2.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  IF flag-art THEN RUN bouton.r (101001,a-lang).
  ELSE DO:
     {&out} "<div align=~"CENTER~">".
     RUN bouton.r (101001,a-lang).
     {&out} "</div>".
  END.

  END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _CONTROL ab_unmap.lablien3 w-html WEB.output

PROCEDURE ab_unmap.lablien3.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  IF flag-art THEN RUN bouton.r (101095,a-lang).

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _CONTROL ab_unmap.navigue w-html WEB.output

PROCEDURE ab_unmap.navigue.output .
/*------------------------------------------------------------------------------
  Purpose:     Output the value of the field to the WEB stream
               in place of the HTML field definition.
  Parameters:  p-field-defn
  Notes:       
------------------------------------------------------------------------------*/
  DEFINE INPUT PARAMETER p-field-defn AS CHARACTER NO-UNDO.
  
  IF flag-art THEN RUN bouton.r (101000,a-lang).
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK w-html 



/* ************************  Main Code Block  ************************* */

/* Standard Main Block that runs adm-create-objects, initializeObject 
 * and process-web-request.
 * The bulk of the web processing is in the Procedure process-web-request
 * elsewhere in this Web object.
 */
{src/web2/template/hmapmain.i}

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE adm-create-objects w-html  _ADM-CREATE-OBJECTS

PROCEDURE adm-create-objects :
/*------------------------------------------------------------------------------
  Purpose:     Create handles for all SmartObjects used in this procedure.
               After SmartObjects are initialized, then SmartLinks are added.
  Parameters:  <none>
------------------------------------------------------------------------------*/

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE aff_label w-html 

PROCEDURE aff_label :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

  DEF INPUT PARAMETER num  AS INTEGER NO-UNDO.

  FIND erreur WHERE erreur.noerr = num
                AND erreur.lang  = a-lang NO-LOCK NO-ERROR.

  IF AVAILABLE erreur THEN {&out} erreur.libel.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE calcul_mtligne w-html 

PROCEDURE calcul_mtligne :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
{calcul_ligne.i}

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE creation_ligne w-html 

PROCEDURE creation_ligne :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

{creation_ligne.i}

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE decode_tag w-html 

PROCEDURE decode_tag :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

DEF INPUT  PARAMETER ligne    AS CHARACTER           NO-UNDO.
DEF INPUT  PARAMETER ancre    AS CHARACTER           NO-UNDO.
DEF OUTPUT PARAMETER lst-tag  AS CHARACTER           NO-UNDO.

DEF VAR i              AS INTEGER           NO-UNDO.
DEF VAR j              AS INTEGER           NO-UNDO.
DEF VAR pos            AS INTEGER           NO-UNDO.
DEF VAR tag            AS CHARACTER         NO-UNDO.

REPEAT:
   i = INDEX(ligne,"<!--").
   j = IF INDEX(ligne,"-->") <> 0 THEN INDEX(ligne,"-->") + 2 ELSE LENGTH(ligne).
   IF i = 0 THEN LEAVE.
   tag = SUBSTRING(ligne,i,j - i + 1).
   pos = INDEX(tag,"<!--WSTAG").
   IF pos <> 0 THEN DO:
      pos = INDEX(tag,ancre).
      IF pos <> 0 AND LOOKUP(tag,lst-tag) = 0 THEN lst-tag = lst-tag + "," + tag.
   END.
   ligne = SUBSTRING(ligne,j + 1).
END.
lst-tag = SUBSTRING(lst-tag,2).

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE htmOffsets w-html  _WEB-HTM-OFFSETS

PROCEDURE htmOffsets :
/*------------------------------------------------------------------------------
  Purpose:     Runs procedure to associate each HTML field with its
               corresponding widget name and handle.
  Parameters:  
  Notes:       
------------------------------------------------------------------------------*/
  RUN readOffsets ("{&WEB-FILE}":U).
  RUN htmAssociate
    ("article_bas":U,"ab_unmap.article_bas":U,ab_unmap.article_bas:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("article_ent":U,"ab_unmap.article_ent":U,ab_unmap.article_ent:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("article_sais":U,"ab_unmap.article_sais":U,ab_unmap.article_sais:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("Err_date":U,"ab_unmap.Err_date":U,ab_unmap.Err_date:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("Err_deci":U,"ab_unmap.Err_deci":U,ab_unmap.Err_deci:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("lablien2 --":U,"ab_unmap.lablien2":U,ab_unmap.lablien2:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("lablien3 --":U,"ab_unmap.lablien3":U,ab_unmap.lablien3:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("lang":U,"ab_unmap.alang":U,ab_unmap.alang:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("monnaie_doc":U,"ab_unmap.monnaie_doc":U,ab_unmap.monnaie_doc:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("navigue":U,"ab_unmap.navigue":U,ab_unmap.navigue:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("par-id":U,"ab_unmap.par-id":U,ab_unmap.par-id:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("par-nosui":U,"ab_unmap.par-nosui":U,ab_unmap.par-nosui:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("par-retour":U,"ab_unmap.par-retour":U,ab_unmap.par-retour:HANDLE IN FRAME {&FRAME-NAME}).
  RUN htmAssociate
    ("refs":U,"ab_unmap.refs":U,ab_unmap.refs:HANDLE IN FRAME {&FRAME-NAME}).
END PROCEDURE.


/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE modification_document w-html 

PROCEDURE modification_document :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
DEF            VAR i             AS   INTEGER             NO-UNDO.
DEF            VAR j             AS   INTEGER             NO-UNDO.
DEF            VAR buf-qte       AS   INTEGER             NO-UNDO.
DEF            VAR buf-ref       AS   CHARACTER           NO-UNDO.
DEF            VAR buf-art       AS   CHARACTER           NO-UNDO.
DEF            VAR flag-monnaie  AS LOGICAL               NO-UNDO.

DO WITH FRAME {&FRAME-NAME}:
   {calcul_document.i}
END.

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE outputHeader w-html 

PROCEDURE outputHeader :
/*------------------------------------------------------------------------
  Purpose:     Output the MIME header, and any "cookie" information needed 
               by this procedure.  
  Parameters:  <none>
  Notes:       In the event that this Web object is state-aware, this is 
               a good place to set the WebState and WebTimeout attributes.
------------------------------------------------------------------------*/

  /* To make this a state-aware Web object, pass in the timeout period
   * (in minutes) before running outputContentType.  If you supply a 
   * timeout period greater than 0, the Web object becomes state-aware 
   * and the following happens:
   *
   *   - 4GL variables webState and webTimeout are set
   *   - a cookie is created for the broker to id the client on the return trip
   *   - a cookie is created to id the correct procedure on the return trip
   *
   * If you supply a timeout period less than 1, the following happens:
   *
   *   - 4GL variables webState and webTimeout are set to an empty string
   *   - a cookie is killed for the broker to id the client on the return trip
   *   - a cookie is killed to id the correct procedure on the return trip
   *
   * For example, set the timeout period to 5 minutes.
   *
   *   setWebState (5.0).
   */
    
  /* Output additional cookie information here before running outputContentType.
   *   For more information about the Netscape Cookie Specification, see
   *   http://home.netscape.com/newsref/std/cookie_spec.html  
   *   
   *   Name         - name of the cookie
   *   Value        - value of the cookie
   *   Expires date - Date to expire (optional). See TODAY function.
   *   Expires time - Time to expire (optional). See TIME function.
   *   Path         - Override default URL path (optional)
   *   Domain       - Override default domain (optional)
   *   Secure       - "secure" or unknown (optional)
   * 
   *   The following example sets custNum=23 and expires tomorrow at (about)
   *   the same time but only for secure (https) connections.
   *      
   *   RUN SetCookie IN web-utilities-hdl 
   *     ("custNum":U, "23":U, TODAY + 1, TIME, ?, ?, "secure":U).
   */ 
  output-content-type ("text/html":U).
  
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE process-web-request w-html 

PROCEDURE process-web-request :
/*------------------------------------------------------------------------
  Purpose:     Process the web request.
  Notes:       
------------------------------------------------------------------------*/
       /* STEP 0 -
   * Output the MIME header and set up the object as state-less or state-aware. 
   * This is required if any HTML is to be returned to the browser. 
   *
   * NOTE: Move 'RUN outputHeader.' to the GET section below if you are going
   * to simulate another Web request by running a Web Object from this
   * procedure.  Running outputHeader precludes setting any additional cookie
   * information.
   */ 
   
  a-lang = INTEGER(get-field("lang")).
  IF a-lang = 0 THEN a-lang = 2.

  IF get-cookie("SessionId") <> "" THEN DO:
     ASSIGN buf-nocli  = INTEGER(ENTRY(1,get-cookie("SessionId")))
            buf-prefix = ENTRY(2,get-cookie("SessionId"))
            buf-nodoc  = INTEGER(ENTRY(3,get-cookie("SessionId"))).
  END.

  FIND doce WHERE doce.nosoc  = 1
              AND doce.typdoc = "PA"
              AND doce.prefix = buf-prefix
              AND doce.nodoc  = buf-nodoc NO-LOCK NO-ERROR.

  IF buf-prefix = "" OR NOT AVAILABLE doce THEN DO:
     FIND LAST doce WHERE doce.nosoc  = 1
                      AND doce.typdoc = "PA"
                      AND doce.prefix = "CAD"
                      NO-LOCK NO-ERROR.
     buf-prefix = "CAD".
     buf-nodoc  = IF AVAILABLE doce THEN doce.nodoc + 1 ELSE 1.
     CREATE doce.
     ASSIGN doce.nosoc  = 1
            doce.typdoc = "PA"
            doce.prefix = "CAD"
            doce.nodoc  = buf-nodoc
            doce.noadrf = IF buf-nocli = 0 THEN 1000 ELSE buf-nocli
            doce.csmtf  = 0
            doce.noadrl = IF buf-nocli = 0 THEN 1000 ELSE buf-nocli
            doce.csmtl  = 0
            doce.cours  = 1
            doce.unit   = 1
            doce.nodos  = 61
            doce.datdoc = TODAY
            doce.dval   = TODAY
            doce.ref    = STRING(TIME,"HH:MM").

     FIND adrd WHERE adrd.nosoc = doce.nosoc
                 AND adrd.noadr = doce.noadrl
                 AND adrd.csmt  = doce.csmtl NO-LOCK NO-ERROR.

     doce.taux   = adrd.codicha.
     doce.codmon = adrd.codmon.

     IF adrd.adrfac <> 0 THEN ASSIGN doce.noadrf = adrd.adrfac
                                     doce.csmtf  = adrd.csmtfac.

     IF doce.noadrf <> 1001 THEN DO:
        FIND FIRST mon WHERE mon.nosoc  = doce.nosoc
               AND mon.codmon = doce.codmon
               AND mon.boucl  = ""
               AND mon.datc  <= doce.datdoc NO-LOCK NO-ERROR.
        IF AVAILABLE mon THEN ASSIGN doce.cours = mon.cours
                                     doce.unit  = mon.unit.
        ELSE ASSIGN doce.cours = 1
                    doce.unit  = 1.
     END.
     ELSE ASSIGN doce.cours = 1
                 doce.unit  = 1.

     RUN SetCookie IN web-utilities-hdl
         ("SessionId",STRING(buf-nocli) + ",CAD," + STRING(doce.nodoc),?,?,?,?,?).

  END.

  RUN outputHeader.
  
  /* Describe whether to receive FORM input for all the fields.  For example,
   * check particular input fields (using GetField in web-utilities-hdl). 
   * Here we look at REQUEST_METHOD. 
   */
  IF REQUEST_METHOD = "POST":U THEN DO:
    /* STEP 1 -
     * Copy HTML input field values to the Progress form buffer. */
    RUN inputFields.

    /* STEP 2 -
     * Open the database or SDO query and and fetch the first record. */
    RUN findRecords.

    DO WITH FRAME {&FRAME-NAME}:

       FIND doce WHERE ROWID(doce) = TO-ROWID(get-field("par-id")) NO-ERROR.


       FIND erreur WHERE erreur.noerr = 101000
                     AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
       lab-bouton[1] = ENTRY(1,erreur.libel).

       FIND erreur WHERE erreur.noerr = 101001
                     AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
       lab-bouton[2] = ENTRY(1,erreur.libel).

       FIND erreur WHERE erreur.noerr = 101095
                     AND erreur.lang  = a-lang NO-LOCK NO-ERROR.
       lab-bouton[3] = ENTRY(1,erreur.libel).

       action  = get-field("bouton").
       IF action = "" THEN action = lab-bouton[1].

       RUN modification_document.

       FIND FIRST docld WHERE docld.nosoc  = doce.nosoc
                          AND docld.typdoc = doce.typdoc
                          AND docld.prefix = doce.prefix
                          AND docld.nodoc  = doce.nodoc
                          AND docld.ref   <> "" NO-LOCK NO-ERROR.
       
       flag-lgdoc = AVAILABLE docld.

    END.

    /* STEP 3 -
     * AssignFields will save the data in the frame.
     * (it automatically upgrades the lock to exclusive while doing the update)
     *
     *  If a new record needs to be created set AddMode to true before
        running assignFields.
     *     setAddMode(TRUE).
     * RUN assignFields. */

    /* STEP 4 -
     * Decide what HTML to return to the user. Choose STEP 4.1 to simulate
     * another Web request -OR- STEP 4.2 to return the original form (the
     * default action).
     *
     * STEP 4.1 -
     * To simulate another Web request, change the REQUEST_METHOD to GET
     * and RUN the Web object here.  For example,
     *
     *  ASSIGN REQUEST_METHOD = "GET":U.
     *  RUN run-web-object IN web-utilities-hdl ("myobject.w":U).
     */

    IF action = lab-bouton[2] THEN DO:
       ASSIGN REQUEST_METHOD = "GET":U.
       RUN run-web-object IN web-utilities-hdl (get-field("par-retour")).
       RETURN.
    END.

    IF action = lab-bouton[3] THEN DO:
       ASSIGN REQUEST_METHOD = "GET":U.
       IF buf-nocli = 0 THEN
          RUN run-web-object IN web-utilities-hdl ("commande_ident.w?lang=" + STRING(a-lang)).
       ELSE RUN run-web-object IN web-utilities-hdl ("commande_envoi.w?lang=" + STRING(a-lang)).
       RETURN.
    END.

    /* STEP 4.2 -
     * To return the form again, set data values, display them, and output
     * them to the WEB stream.
     *
     * STEP 4.2a -
     * Set any values that need to be set, then display them. */
    RUN displayFields.

    /* STEP 4.2b -
     * Enable objects that should be enabled. */
    RUN enableFields.

    par-retour:SCREEN-VALUE = get-field("par-retour").
    par-id:SCREEN-VALUE = STRING(ROWID(doce)).
    refs:SCREEN-VALUE   = "".
    alang:SCREEN-VALUE   = STRING(a-lang).

    /* STEP 4.2c -
     * OUTPUT the Progress form buffer to the WEB stream. */
    RUN outputFields.

  END. /* Form has been submitted. */

  /* REQUEST-METHOD = GET */
  ELSE DO:
    /* This is the first time that the form has been called. Just return the
     * form.  Move 'RUN outputHeader.' here if you are going to simulate
     * another Web request. */

/*     RUN outputHeader.  */

    /* STEP 1 -
     * Open the database or SDO query and and fetch the first record. */
    RUN findRecords.


    /* Return the form again. Set data values, display them, and output them
     * to the WEB stream.
     *
     * STEP 2a -
     * Set any values that need to be set, then display them. */
    RUN displayFields.

    /* STEP 2b -
     * Enable objects that should be enabled. */
    RUN enableFields.

    FIND doce WHERE doce.nosoc  = 1
                AND doce.typdoc = "PA"
                AND doce.prefix = buf-prefix
                AND doce.nodoc  = buf-nodoc NO-ERROR.

    FIND erreur WHERE erreur.noerr = 101033
                  AND erreur.lang  = a-lang NO-LOCK NO-ERROR.

    DO WITH FRAME {&FRAME-NAME}:
       par-id:SCREEN-VALUE = STRING(ROWID(doce)).
       refs:SCREEN-VALUE   = get-field("id").
       par-retour:SCREEN-VALUE = IF get-field("retour") = "" THEN 
                                    IF flag-art THEN "commande.w"
                                    ELSE "article.w"
                                 ELSE get-field("retour").
       monnaie:SCREEN-VALUE = doce.codmon.
       alang:SCREEN-VALUE   = STRING(a-lang).

    END.

    ASSIGN buf-ref = get-field("id")
           buf-qte = 1.

    FIND LAST docld WHERE docld.nosoc  = doce.nosoc
                      AND docld.typdoc = doce.typdoc
                      AND docld.prefix = doce.prefix
                      AND docld.nodoc  = doce.nodoc
                      NO-LOCK NO-ERROR.

    IF AVAILABLE docld AND docld.ref = buf-ref THEN buf-qte = 0.

    FIND arti WHERE arti.nosoc = doce.nosoc
                AND arti.ref   = buf-ref  NO-LOCK NO-ERROR.

    IF buf-qte <> 0 AND buf-ref <> "" THEN
       RUN creation_ligne (buf-ref,buf-qte).


    FIND FIRST docld WHERE docld.nosoc  = doce.nosoc
                       AND docld.typdoc = doce.typdoc
                       AND docld.prefix = doce.prefix
                       AND docld.nodoc  = doce.nodoc
                       AND docld.ref   <> "" NO-LOCK NO-ERROR.
    flag-lgdoc = AVAILABLE docld.

    /* STEP 2c -
     * OUTPUT the Progress from buffer to the WEB stream. */
    RUN outputFields.

  END.
  
  /* Show error messages. */
  IF AnyMessage() THEN 
  DO:
     /* ShowDataMessage may return a Progress column name. This means you
      * can use the function as a parameter to HTMLSetFocus instead of 
      * calling it directly.  The first parameter is the form name.   
      *
      * HTMLSetFocus("document.DetailForm",ShowDataMessages()). */
     ShowDataMessages().
  END.
 
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

 _UIB-CODE-BLOCK _PROCEDURE remplace_tag w-html 

PROCEDURE remplace_tag :
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

DEF INPUT        PARAMETER ancre    AS   CHARACTER        NO-UNDO.       
DEF INPUT        PARAMETER nombre   AS   INTEGER          NO-UNDO.       
DEF INPUT        PARAMETER tag      AS   CHARACTER        NO-UNDO.       
DEF INPUT        PARAMETER texte    AS   CHARACTER        NO-UNDO.       
DEF INPUT-OUTPUT PARAMETER ligne    AS   CHARACTER        NO-UNDO.
DEF VAR i          AS   INTEGER                    NO-UNDO.

DO i = 1 TO nombre:
   IF INDEX(tag,ancre + STRING(i,"99")) <> 0 THEN ligne = REPLACE(ligne,tag,ENTRY(i,texte,"#")).
END.
END PROCEDURE.

/* _UIB-CODE-BLOCK-END */

